package com.example.newinfinity.MyViewModel

import android.graphics.Bitmap
import android.graphics.BitmapFactory
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.newinfinity.Account.MyWorks.WorksModel
import com.example.newinfinity.Account.MyWorks.getImageModel

/*我的作品 预览与具体查看图片的viewModel*/
class PhotoBrowserViewModel : ViewModel() {
    val imageModels: LiveData<ArrayList<WorksModel>> = MutableLiveData(getImageModel())

    //保存当前点击进入图片详情的当前图片（显示该图片阴影及图片信息）
    var currentClickImageModel:WorksModel? = null

    //根据当前点击的图片返回一个bitmap
    fun returnCurrentImageBitmap():Bitmap{
        val bitmap = BitmapFactory.decodeFile(currentClickImageModel?.thumbnailPath)
        return bitmap
    }

    fun removeAllImages(images: ArrayList<WorksModel>) {
        imageModels.value?.removeAll(images)
    }
}